using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace TestGUI
{
	/// <summary>
	/// This class is the form that allows the manager to set the target number of employees to work per shift.
	/// </summary>
	public class AdminPrefs : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.NumericUpDown employeeCounter;
		private System.Windows.Forms.Button saveButton;
		private System.Windows.Forms.Button cancelButton;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		Session ses;

		public AdminPrefs()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}
	
		public AdminPrefs(Session s) 
		{
			InitializeComponent();
			ses = s;
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			this.Owner.Visible = true;
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.label1 = new System.Windows.Forms.Label();
			this.employeeCounter = new System.Windows.Forms.NumericUpDown();
			this.saveButton = new System.Windows.Forms.Button();
			this.cancelButton = new System.Windows.Forms.Button();
			this.groupBox1.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.employeeCounter)).BeginInit();
			this.SuspendLayout();
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.label1);
			this.groupBox1.Controls.Add(this.employeeCounter);
			this.groupBox1.Location = new System.Drawing.Point(8, 8);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(184, 64);
			this.groupBox1.TabIndex = 0;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Admin";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(8, 16);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(72, 40);
			this.label1.TabIndex = 1;
			this.label1.Text = "Employees per shift";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// employeeCounter
			// 
			this.employeeCounter.Location = new System.Drawing.Point(96, 24);
			this.employeeCounter.Maximum = new System.Decimal(new int[] {
																			30,
																			0,
																			0,
																			0});
			this.employeeCounter.Minimum = new System.Decimal(new int[] {
																			1,
																			0,
																			0,
																			0});
			this.employeeCounter.Name = "employeeCounter";
			this.employeeCounter.Size = new System.Drawing.Size(56, 20);
			this.employeeCounter.TabIndex = 0;
			this.employeeCounter.Value = new System.Decimal(new int[] {
																		  2,
																		  0,
																		  0,
																		  0});
			// 
			// saveButton
			// 
			this.saveButton.Location = new System.Drawing.Point(8, 88);
			this.saveButton.Name = "saveButton";
			this.saveButton.Size = new System.Drawing.Size(88, 24);
			this.saveButton.TabIndex = 1;
			this.saveButton.Text = "Save";
			this.saveButton.Click += new System.EventHandler(this.saveButton_Click);
			// 
			// cancelButton
			// 
			this.cancelButton.Location = new System.Drawing.Point(104, 88);
			this.cancelButton.Name = "cancelButton";
			this.cancelButton.Size = new System.Drawing.Size(88, 24);
			this.cancelButton.TabIndex = 1;
			this.cancelButton.Text = "Cancel";
			this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
			// 
			// AdminPrefs
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(200, 118);
			this.Controls.Add(this.saveButton);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.cancelButton);
			this.Name = "AdminPrefs";
			this.Text = "Administrator Preferences";
			this.Load += new System.EventHandler(this.AdminPrefs_Load);
			this.groupBox1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.employeeCounter)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void cancelButton_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void saveButton_Click(object sender, System.EventArgs e)
		{
			ses.setEmployeesPerShift(Decimal.ToInt32(employeeCounter.Value));
			this.Close();
		}

		private void AdminPrefs_Load(object sender, System.EventArgs e)
		{
			employeeCounter.Value = Decimal.Parse(ses.getEmployeesPerShift());
		}
		
	}
}
